package com.tangerine.sonar;

import com.tangerine.servicios.ServicioHistorial;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

public class SplashActivity extends Activity{

	static final String TAG = "SplashActivity";

	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        Log.d(TAG, "OnCreate");
        
        Thread logoTimer = new Thread(){			
			public void run(){
				try {
					Intent intent = new Intent(SplashActivity.this,MainActivity.class);
					((SonarApp)getApplication()).initTTS();
					sleep(3500);
					((SonarApp)getApplication()).decir("Iniciando sintetizador de voz");
					sleep(3000);
					((SonarApp)getApplication()).decir("Iniciando indors");
					if(((SonarApp)getApplication()).bSonarPrimeraCorrida)
						sleep(10000);
					else 
						sleep(4000);
					((SonarApp)getApplication()).decir("indors iniciado");
					sleep(2000);
					((SonarApp)getApplication()).decir("Cargando Edificio, espere por favor");
					sleep(7500);
					((SonarApp)getApplication()).decir("Espere por favor");
					sleep(7500);
					((SonarApp)getApplication()).decir("Edificio Cargado");
					sleep(2500);
					((SonarApp)getApplication()).decir("iniciando sonar");
					sleep(2500);
					startActivity(intent);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				finally
				{
				 finish();
				}
			}
		};
		logoTimer.start();

    }
    
    protected void onDestroy(){
    	super.onDestroy();
    	ServicioHistorial srvHistorial = new ServicioHistorial(); 	
    	srvHistorial.eliminarHistorial();

    }
}
